package com.z2.disruptor;

import com.z2.disruptor.producer.LongEventProducerWithTranslator;

import java.nio.ByteBuffer;

/**
 * Created by cdyizuoming on 2017/11/10.
 */
public class TestTask implements Runnable {

    LongEventProducerWithTranslator producer;

    private int total;

    public TestTask(LongEventProducerWithTranslator producer, int total) {
        this.producer = producer;
        this.total = total;
    }

    public void run() {
        ByteBuffer bb = ByteBuffer.allocate(8);//预置8字节长整型字节缓存
        for (long l = 0; l < total; l++) {
            bb.putLong(0, l);
            producer.product(bb);//生产者生产数据
        }

    }
}
